//
//  qaViewController.m
//  RealEstateQa
//
//  Created by 张立彬 on 13-7-12.
//  Copyright (c) 2013年 com.rong360. All rights reserved.
//

#import "qaViewController.h"
#import "DrawView.h"

@interface qaViewController ()

@end

@implementation qaViewController

//标题
@synthesize DataTitle;

//描述
@synthesize DataDesc;

//列表数据
@synthesize DataList;

//问答列表
@synthesize DataQa;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //声明DrawView类
    Dv = [[DrawView alloc]init];

    //初始化ViewWrap
    //CGRect _frame = [UIScreen mainScreen].applicationFrame;
    ViewWrap = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,480)];
    [self.view addSubview:ViewWrap];
    
    //[self initQa];
    [self initTable];
    
    //DataDesc = @"ssss";
    //[Dv image:ViewWrap style:@"{{133, 24}, {54, 54}}" src:@"jsq"];
    //[Dv label:ViewWrap style:@"{{15, 250}, {200, 30}}" text:@"融360出品"];

    DataList = @[@"北京",@"上海",@"广州",@"深圳"];
    DataQa = @[@"2在北京交的社保公积金我在北京上班，在北京交的社保公积金，想在老家广州买房子，可以在北京办公积金贷款吗可以在北京办公积金贷款吗？",@"2您要买的房屋在广州，所以只能在广州办理贷款，城市请选择广州。"];
    [self.view addSubview:TableList];
    /*
    [self DrawView:ViewWrap
           title:@"ddddd"
            desc:@"ssss"
           table: TableList
              qa: TableQa
     ];
*/
    
}

//画制视图
-(void)DrawView:(UIView *)wrap
//标题
          title:(NSString *)title
//描述
           desc:(NSString *)desc
//表格
          table:(UITableView *)table
//qa表格
             qa:(UITableView *)qa

{
    CGRect _frame = [UIScreen mainScreen].applicationFrame;
    UIScrollView *s = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, _frame.size.height - 40)];
    ScrollBody = s;
    s.pagingEnabled = YES;
    //s.backgroundColor = [UIColor blueColor];
    s.showsVerticalScrollIndicator = NO;
    s.showsHorizontalScrollIndicator = NO;
    [s setContentSize:CGSizeMake(320,_frame.size.height + 30)];
    //s.delegate = self;
    [wrap addSubview:s];
    
    //加载步骤说明
    [self loadDesc:s title: title desc: desc];
    
    //加载表格数据
    //RealEstateQaViewController *Rc = [[RealEstateQaViewController alloc] init];
    //tableview.delegate = Rc.self;
    [s addSubview:table];
    [s addSubview:qa];
}

//加载步骤说明
-(void)loadDesc:(UIScrollView *)wrap title:(NSString *)title desc:(NSString *)desc{
    //加载标题
    UILabel *LabTitle = [[UILabel alloc] initWithFrame: CGRectMake(10, 10, 320, 30)];
    //设置字体
    [LabTitle setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]];
    //设置背景为透明
    [LabTitle setBackgroundColor:[UIColor clearColor]];
    //写入文本
    [LabTitle setText:title];
    
    //追加进容器
    [wrap addSubview:LabTitle];
    
    //加载说明
    //加载标题
    UITextView *TextDesc = [[UITextView alloc] initWithFrame: CGRectMake(10, 40, 300, 10)];
    
    //设置字体
    [TextDesc setFont:[UIFont fontWithName:@"Helvetica" size:14]];
    //设置背景为透明
    [TextDesc setBackgroundColor:[UIColor clearColor]];
    //写入文本
    [TextDesc setText:desc];
    
    //设置不可编辑
    [TextDesc setEditable:NO];
    //设置不可滚动
    [TextDesc setScrollEnabled:NO];
    
    //追加进容器
    [wrap addSubview:TextDesc];
    
    //动太更新调试
    CGRect frame;
    frame = TextDesc.frame;
    frame.size.height = [TextDesc contentSize].height;
    TextDesc.frame = frame;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//初始化表格
-(void)initTable{
    //加载表格
    TableList = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    TableList.hidden = NO;
    TableList.delegate = self;
    TableList.dataSource = self;
    TableList.scrollEnabled = NO;
    //构造模拟数据
    TableList.layer.borderWidth = 1;
    TableList.layer.borderColor =  [[UIColor colorWithRed:(219/255.0) green:(225/255.0) blue:(228/255.0) alpha:1] CGColor];
    
}
//初始化表格
-(void)initQa{
    //加载表格
    TableQa = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    TableQa.delegate = self;
    TableQa.dataSource = self;
    TableQa.scrollEnabled = NO;
    //构造模拟数据
    TableQa.layer.borderWidth = 0;
    
    //表格背景透明
    TableQa.backgroundView = nil;
    TableQa.backgroundColor = [UIColor clearColor];
    TableQa.opaque = NO;
}

@end
